package com.xudow.app.newui.adapter;

import android.support.v4.app.FragmentActivity;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.xudow.app.R;
import com.xudow.app.newui.bean.NianJi;

import java.util.List;

/**
 * 作者：LownChen on 2016/9/2 10:05
 */
public class NianJiAdapter extends BaseAdapter{

    FragmentActivity activity;
    List<NianJi.GradeEntity> list;
    public NianJiAdapter(FragmentActivity activity, List<NianJi.GradeEntity> list) {
        this.activity=activity;
        this.list=list;

    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if(convertView==null){
            convertView= LayoutInflater.from(activity).inflate(R.layout.item_nianji,null);
            holder=new ViewHolder(convertView);
          convertView.setTag(holder);
        }else{

            holder=(ViewHolder)convertView.getTag();
        }
          holder.tv.setText(list.get(position).getGradeName());

        return convertView;
    }

    class ViewHolder{

        TextView tv;

        public ViewHolder(View convertView) {
            tv=(TextView)convertView.findViewById(R.id.tvnianji_item);
        }
    }

}
